<%--
	fileName      : personal_shortcutmenudefine.jsp
	author        : kfzx-liukai
	createDate    : 2010-6-10  上午12:52:23
	lastModifier  : kfzx-liukai
	lastModifyDate: 2010-6-10  上午12:52:23
	description   : 快捷菜单定制
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="ctp-tag" prefix="ctp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title><ctp:label key='quick_menu_list'/></title>
		<ctp:include items='borderlayout,panel,toolbar,tabletree,button,message_ex'/>
		<script type='text/javascript' kind='variant'>		  
		    //================================UI变量定义片段============================================================
		    var ctpBorderlayout;//页面框架布局器
		    var ctpToolbar;//工具条
		    var ctpTabletree;//表树
		    var ctpPanel;//Panel		    
		</script>
		<script type='text/javascript' kind='event'>		    
			//================================函数定义片段============================================================
			/**
             * 保存快捷菜单
             * @version	 1.0
             * @since	 1.0
             * @author	kfzx-liukai           
             */
			function saveShortcutmenu(){               
			    var _fnContext = "personal_shortcutmenudefine.jsp" + "->saveShortcutmenu()";
			    try {                  
			    	if(confirmModify()){
	                	document.GotoShortCutMenuList.submit();
	                }  
			    } 
			    catch (e) {
			        ctp.core.log.err(_fnContext, e.message);
			    }  
			}
			/**
             * 校验快捷菜单
             * @version	 1.0
             * @since	 1.0
             * @author	kfzx-liukai           
             */
            function confirmModify(){
            	var _fnContext = "personal_shortcutmenudefine.jsp" + "->confirmModify()";
			    try {
			    	var maxCount = "5";
			    	var itemSelect = $('input[name="itemId"]');
		  			//var itemSelect = document.all.item("itemId");
		  			var selected = new Array();
		  			var count = 0;
		  			for (var i=0;i<itemSelect.length;i++){
		  				//if ($(itemSelect[i]).attr('checked')) {
		  				if (itemSelect.eq(i).attr('checked')) {
		  			    	if (contains(selected, itemSelect.get(i).getAttribute("value"))) {
		  			        	continue;
		  			        } else {
		  			        	selected[count] = itemSelect.get(i).getAttribute("value");
		  			        	count++;
		  			        }
		  			    }
		  			    if (count > maxCount) {
		  			    	var strMsg = "<ctp:label key='shortmenu1'/>" + maxCount + "<ctp:label key='shortmenu2'/>";
		  			    	ctpMSB.error({title:'<ctp:label key="error_msg"/>',message:strMsg});
		  			    	return false;
		  			    }
		  			}
		  			return true;
			    } 
			    catch (e) {
			        ctp.core.log.err(_fnContext, e.message);
			    }
			}
			/**
	         * 取消按钮
	         * @version	 1.0
	         * @since	 1.0
	         * @author	kfzx-liukai           
	         */
			function btnCancel(){               
				var _fnContext = "personal_shortcutmenudefine.jsp" + "->btnCancel()";
				try {                  
				    history.go(-1);
				} 
				catch (e) {
				    ctp.core.log.err(_fnContext, e.message);
				}  
			}
            /**
             * 校验数组
             * @version	 1.0
             * @since	 1.0
             * @author	kfzx-liukai           
             */
  			function contains(array, item) {
  			    if (array != null) {
  			        for (var i=0; i<array.length; i++) {
  			            if (array[i] == item) {
  			                return true;
  			            }
  			        }
  			    }
  			    return false;
  			}
		</script>
		<script type='text/javascript' kind='notUi'>
			//================================非UI组件定义片段==========================================================
			var myurl='<ctp:url href="personal.flowc" flowActionName="authusershortcutmenudefineop" />';
		</script>
		<script type='text/javascript' kind='ui'>
			//================================UI组件定义片段============================================================
			/**
	         * 创建UI组件
	         * @version	 1.0
	         * @since	 1.0
	         * @author	kfzx-liukai           
	         */		    
		    function initUI(){
		    	var _mContext = "personal_shortcutmenulist.jsp -> initUI()";
		     	try {
	       	 		//创建页面框架布局器
	       	 		ctpBorderlayout = new ctp.ui.borderlayout({
	                    type: "1C",
	                    center__scrollable:true
	                });
	       	 		ctpBorderlayout.create();
	       	           	    	
	       	 		$('#form1').parent().appendTo(ctpBorderlayout.panes.center);
	       	 	    
	       	 		//创建工具条
	       	 		ctpToolbar=new ctp.ui.toolbar({
		       	 		leftItems :[
		    		       	{
								id:"_toolbar_button_confirm",
				                type : 'button',
				                text : '<ctp:label key="confirm"/>',
				                icon : 'apply',
				                onClick : saveShortcutmenu
		               		},'-',{
								id:"_toolbar_button_cancel",
				                type : 'button',
				                text : '<ctp:label key="return"/>',
				                icon : 'back',
				                onClick : btnCancel
	                		}
			         	]//,            			
						//renderTo:'form1'				   
				    });
	       	    	ctpTabletree = new ctp.ui.tabletree({
			    	    actionPos:1,
			    	    width: '100%',
			    	    height:'100%',
			    	    check:false,
			    	    checkType:'radio',
			      	    tableHead:[[{text:'<ctp:label key="module_name"/>'},{text:'<ctp:label key="select"/>'}]],
			    	    url:myurl,
			    	    tdTitle:false,
			    	    id:'shortcutmentTabletree'
			        });
	       	 	    $('#form1').height($('body').height()-20);
	       	 		ctpPanel = new ctp.ui.panel({
						id: 'shortcutmentPanel',
			            title: '<ctp:label key="select_need_menu"/>',
			            collapsible: true,
			            height: '100%',
			            width: 'auto',
			            toolbar:ctpToolbar,
			            toolbarPos:'outertop',
			            bodyPadding:'0',
			            items:[ctpTabletree],
			            renderTo: 'form1'
			        });
	       	 	    //ctpPanel.setWidth($('body').width());
	       	 	    //ctpPanel.resize();
	       	 		
	       	 	}
			    catch (e) {
			        ctp.core.log.err(_mContext, e.message);
			    } 
			}
		</script>
	</head>
	<body onload='initUI()' style="height:100%;">
		<ctp:form name="GotoShortCutMenuList" method="post" action="personal.flowc" flowActionName="updateShortCutMenu">
			<div id="form1" style="height:100%;border:0px;padding:0px;margin:0px"></div>
		</ctp:form>
	</body>
</html>

<%--
	date        :
	modifyReason:
--%>